API Documentation
Matrix.h
1 // Matrix.h
3 //
5 
6 namespace nkMaths
7 {
13  class Matrix : public ByteAlignedClass<16>
14  {
15  public :
16 
17  union
18  {
19  std::array<std::array<float, 4>, 4> _m ;
20  std::array<std::array<float, 4>, 4> m ;
21  } ;
22 
23  public :
24 
29  Matrix () ;
41  Matrix (float m00, float m01, float m10, float m11) ;
58  Matrix (float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22) ;
81  Matrix (float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33) ;
87  Matrix (const Matrix& other) ;
91  ~Matrix () ;
92 
93  // Getters
97  Vector getRow0 () const ;
101  Vector getRow1 () const ;
105  Vector getRow2 () const ;
109  Vector getRow3 () const ;
113  Vector getCol0 () const ;
117  Vector getCol1 () const ;
121  Vector getCol2 () const ;
125  Vector getCol3 () const ;
134  float get (unsigned int row, unsigned int col) const ;
135 
136  // Setters
146  Matrix& set (float val, unsigned int row, unsigned int col) ;
147 
148  // Alterations
164  Matrix getTranspose () const ;
189 
190  // Transformations
216  void getDecomposed (Vector& position, Quaternion& orientation, Vector& scale) ;
217 
226  Matrix& setToViewMatrixDirection (const Vector& position, const Vector& direction, const Vector& upDirection) ;
239  Matrix& setToPerspectiveMatrix (float fov, float aspect, float nearVal, float farVal) ;
252  Matrix& setToOrthographicMatrix (float widthNearPlane, float heightNearPlane, float nearVal, float farVal) ;
259  Matrix& setPositionComponent (const Vector& position) ;
273  Matrix& setScaleComponent (const Vector& scale) ;
282  Matrix& setToTransformation (const Vector& position, const Quaternion& orientation, const Vector& scale) ;
283 
291  Vector transform (const Vector& vector) const ;
292 
293  // Utilities
297  float getDeterminantMat2 () const ;
301  float getDeterminantMat3 () const ;
305  float getDeterminantMat4 () const ;
309  float getTraceMat3 () const ;
313  float getTraceMat3 () const ;
317  float getTraceMat4 () const ;
318 
328 
329  // Operators
336  Matrix& operator= (const Matrix& other) ;
343  bool operator== (const Matrix& other) ;
350  bool operator!= (const Matrix& other) ;
357  Matrix operator+ (const Matrix& other) const ;
363  void operator+= (const Matrix& other) ;
370  Matrix operator- (const Matrix& other) const ;
376  void operator-= (const Matrix& other) ;
383  Matrix operator* (const Matrix& other) const ;
390  Vector operator* (const Vector& toApply) const ;
397  Matrix operator* (float scalar) const ;
403  void operator*= (const Matrix& other) ;
409  void operator*= (float scalar) ;
416  Matrix operator/ (float scalar) const ;
422  void operator /= (float scalar) ;
423  } ;
424 }
nkMaths::Matrix::getTraceMat4
float getTraceMat4() const
nkMaths::Matrix::~Matrix
~Matrix()
nkMaths::Matrix::setToPerspectiveMatrix
Matrix & setToPerspectiveMatrix(float fov, float aspect, float nearVal, float farVal)
nkMaths::Matrix::operator!=
bool operator!=(const Matrix &other)
nkMaths::Matrix::getInverseMat3
Matrix getInverseMat3() const
nkMaths::Matrix::getDecomposed
void getDecomposed(Vector &position, Quaternion &orientation, Vector &scale)
nkMaths::Matrix::inverseMat4
Matrix & inverseMat4()
nkMaths::Matrix::getInverseMat4
Matrix getInverseMat4() const
nkMaths::Matrix::setOrientationComponent
Matrix & setOrientationComponent(const Quaternion &rot)
nkMaths::Matrix::operator*
Matrix operator*(const Matrix &other) const
nkMaths
Encompasses all API of component NilkinsMaths.
Definition: IntVector.h:7
nkMaths::Matrix::transpose
Matrix & transpose()
nkMaths::Quaternion
A quaternion, symbolizing rotations as a 4D vector.
Definition: Quaternion.h:14
nkMaths::Matrix::getCol1
Vector getCol1() const
nkMaths::Matrix::setScaleComponent
Matrix & setScaleComponent(const Vector &scale)
nkMaths::Matrix::getCol0
Vector getCol0() const
nkMaths::Matrix::getTraceMat3
float getTraceMat3() const
nkMaths::Matrix::getRow3
Vector getRow3() const
nkMaths::Matrix::getRow2
Vector getRow2() const
nkMaths::Matrix
Represents a 4x4 float matrix.
Definition: Matrix.h:14
nkMaths::Matrix::operator-=
void operator-=(const Matrix &other)
nkMaths::Matrix::getScaleComponent
Vector getScaleComponent() const
nkMaths::Matrix::Matrix
Matrix()
nkMaths::Matrix::getCol3
Vector getCol3() const
nkMaths::Matrix::inverseMat3
Matrix & inverseMat3()
nkMaths::Matrix::operator==
bool operator==(const Matrix &other)
nkMaths::Matrix::getCol2
Vector getCol2() const
nkMaths::Matrix::operator/=
void operator/=(float scalar)
nkMaths::Matrix::setToViewMatrixDirection
Matrix & setToViewMatrixDirection(const Vector &position, const Vector &direction, const Vector &upDirection)
nkMaths::Matrix::getDeterminantMat3
float getDeterminantMat3() const
nkMaths::Matrix::Matrix
Matrix(float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22)
nkMaths::Matrix::Matrix
Matrix(float m00, float m01, float m10, float m11)
nkMaths::Matrix::setPositionComponent
Matrix & setPositionComponent(const Vector &position)
nkMaths::Matrix::getDeterminantMat4
float getDeterminantMat4() const
nkMaths::Matrix::setToOrthographicMatrix
Matrix & setToOrthographicMatrix(float widthNearPlane, float heightNearPlane, float nearVal, float farVal)
nkMaths::Matrix::getDeterminantMat2
float getDeterminantMat2() const
nkMaths::Matrix::transform
Vector transform(const Vector &vector) const
nkMaths::Matrix::operator+
Matrix operator+(const Matrix &other) const
nkMaths::Matrix::operator-
Matrix operator-(const Matrix &other) const
nkMemory::StringView
Class holding information about a string, with no ownership over the data.
Definition: StringView.h:22
nkMaths::Matrix::setToTransformation
Matrix & setToTransformation(const Vector &position, const Quaternion &orientation, const Vector &scale)
nkMaths::Matrix::getRow0
Vector getRow0() const
nkMaths::Matrix::inverseMat2
Matrix & inverseMat2()
nkMaths::Matrix::Matrix
Matrix(float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33)
nkMaths::Matrix::getOrientationComponent
Matrix getOrientationComponent() const
nkMaths::Matrix::operator=
Matrix & operator=(const Matrix &other)
nkMaths::Matrix::Matrix
Matrix(const Matrix &other)
nkMaths::Matrix::getRow1
Vector getRow1() const
nkMaths::Matrix::fromString
Matrix & fromString(const nkMemory::StringView &str)
nkMaths::Matrix::getPositionComponent
Vector getPositionComponent() const
nkMaths::Matrix::operator*=
void operator*=(const Matrix &other)
nkMaths::Vector
A 4-component vector class, with floats.
Definition: Vector.h:12
nkMaths::Matrix::get
float get(unsigned int row, unsigned int col) const
nkMaths::Matrix::getTranspose
Matrix getTranspose() const
nkMaths::Matrix::set
Matrix & set(float val, unsigned int row, unsigned int col)
nkMaths::Matrix::operator/
Matrix operator/(float scalar) const
nkMaths::Matrix::getInverseMat2
Matrix getInverseMat2() const
nkMaths::Matrix::operator+=
void operator+=(const Matrix &other)